import { Column, Entity, Index, PrimaryGeneratedColumn } from "typeorm";

@Index("order_no", ["orderNo"], { unique: true })
@Entity("charge_card_order", { schema: "cabinet" })
export class ChargeCardOrder {
  @PrimaryGeneratedColumn({ type: "int", name: "order_id", unsigned: true })
  orderId: number;

  @Column("varchar", { name: "order_no", unique: true, length: 22 })
  orderNo: string;

  @Column("int", {
    name: "user_id",
    comment: "用户id",
    unsigned: true,
    default: () => "'0'",
  })
  userId: number;

  @Column("int", { name: "card_id", unsigned: true, default: () => "'0'" })
  cardId: number;

  @Column("varchar", { name: "card_no", comment: "卡号", length: 20 })
  cardNo: string;

  @Column("decimal", {
    name: "pre_pay_amount",
    comment: "预付金额",
    precision: 5,
    scale: 2,
    default: () => "'0.00'",
  })
  prePayAmount: string;

  @Column("int", { name: "merchant_id", unsigned: true, default: () => "'0'" })
  merchantId: number;

  @Column("int", {
    name: "sub_merchant_id",
    unsigned: true,
    default: () => "'0'",
  })
  subMerchantId: number;

  @Column("decimal", {
    name: "profit_rate",
    comment: "分润比例",
    precision: 5,
    scale: 2,
    default: () => "'0.00'",
  })
  profitRate: string;

  @Column("tinyint", {
    name: "source",
    comment: "1：线上卡,2:线下卡",
    unsigned: true,
    default: () => "'0'",
  })
  source: number;

  @Column("int", {
    name: "device_id",
    comment: "设备号",
    unsigned: true,
    default: () => "'0'",
  })
  deviceId: number;

  @Column("tinyint", {
    name: "port_no",
    comment: "端口号",
    unsigned: true,
    default: () => "'0'",
  })
  portNo: number;

  @Column("tinyint", {
    name: "strategy_type",
    comment: "策略类型",
    default: () => "'0'",
  })
  strategyType: number;

  @Column("json", {
    name: "strategy_rules",
    nullable: true,
    comment: "策略规则",
  })
  strategyRules: object | null;

  @Column("decimal", {
    name: "unit_price",
    comment: "单价",
    precision: 4,
    scale: 2,
    default: () => "'0.00'",
  })
  unitPrice: string;

  @Column("float", {
    name: "settle_unit",
    comment: "最小计费单位",
    unsigned: true,
    precision: 12,
    default: () => "'0'",
  })
  settleUnit: number;

  @Column("decimal", {
    name: "charge_amount",
    comment: "充电金额",
    precision: 5,
    scale: 2,
    default: () => "'0.00'",
  })
  chargeAmount: string;

  @Column("decimal", {
    name: "fee_amount",
    comment: "扣金额的",
    precision: 5,
    scale: 2,
    default: () => "'0.00'",
  })
  feeAmount: string;

  @Column("decimal", {
    name: "fee_reward_amount",
    comment: "扣奖励的",
    precision: 5,
    scale: 2,
    default: () => "'0.00'",
  })
  feeRewardAmount: string;

  @Column("decimal", {
    name: "consume_amount",
    comment: "实际消费的金额",
    precision: 5,
    scale: 2,
    default: () => "'0.00'",
  })
  consumeAmount: string;

  @Column("tinyint", {
    name: "stop_reason",
    comment: "停止充电原因",
    unsigned: true,
    default: () => "'0'",
  })
  stopReason: number;

  @Column("json", {
    name: "charge_data",
    nullable: true,
    comment: "其它的信息",
  })
  chargeData: object | null;

  @Column("tinyint", {
    name: "status",
    comment: "0:等待开始充电,1:充电中,2:充电完成，3：充电失败",
    unsigned: true,
    default: () => "'0'",
  })
  status: number;

  @Column("tinyint", {
    name: "error_code",
    unsigned: true,
    default: () => "'0'",
  })
  errorCode: number;

  @Column("int", {
    name: "create_time",
    comment: "创建时间",
    unsigned: true,
    default: () => "'0'",
  })
  createTime: number;

  @Column("int", {
    name: "end_time",
    comment: "结束时间",
    unsigned: true,
    default: () => "'0'",
  })
  endTime: number;
}
